<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8">
    <title>Register</title>
    <link href="/layui/css/layui.css" type="text/css" rel="stylesheet">
    <script src="/layui/layui.js"></script>
    <script src="/js/libSys/commonHeader.js" rel="script"></script>
</head>
<body>

<div th:replace="libSys/libSysCommonHeader::libSysCommonHeader"></div>
<br>
<br>
<br>
<div class="layui-container">
    <form action="/register" method="post" class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="username" required  lay-verify="required" id="usernameCheck" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux" id="usernameCheckNotice">提示</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">提示</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-inline">
                <input type="text" name="sex" required  lay-verify="required" placeholder="请输入“男”/“女”" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline">
                <input type="text" name="email" required  lay-verify="required|email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="text" name="telphone" required  lay-verify="required|phone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="registerButton" type="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form','jquery','layer'],function(){
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;
        form.on("submit(registerButton)",function(data){

        });
        $("#usernameCheck").on("change",function(){
            var text = $(this).val();
            $.ajax({
                url:"/registerUsernameCheck/"+text,
                data:text,
                success:function(data){
                    if(data=="no"){
                        layer.msg("用户名已经存在！");
                        $("#usernameCheckNotice").text("用户名已经存在！");
                    }
                    else{
                        $("#usernameCheckNotice").text("该用户名可以注册");
                    }
                }
            });
        });
    });
</script>

</body>
</html>